<script src="design/js/scriptaculous/prototype.js" type="text/javascript"></script>
<script src="design/js/scriptaculous/effects.js" type="text/javascript"></script>
<script src="design/js/scriptaculous/dragdrop.js" type="text/javascript"></script>
<script src="design/js/scriptaculous/controls.js" type="text/javascript"></script>

{if $aFriends}
<table style="width: 100%;" class="mainmenu5" cellpadding="0" cellspacing="0" border="0">
<tr>
    <td width="7"><img src="design/pic/spacer.gif" class="sqr1" alt="" height="7" width="7" /></td>
    <td class="block_header">{language text="my_top_friends"}</td>
</tr>
</table>

<form method="post" action="{url link='current'}">
<div style="padding:8px; font-size:9pt;">
{language text='Mod_Account.total_friends_display'}:
<select name="total_friends" id="total_friends" onchange="window.focus(); sId('totalFriendsSaved').innerHTML='{language text='Mod_Account.saving'}...'; xajax_updateTotalFriends(sId('total_friends').value);">
	<option value="">{language text='select'}</option>
	{html_options options=$aTotalFriends selected=$aTotalSelect}
</select> <span id="totalFriendsSaved"></span>
</div>
</form>

<div id="cart" class="cart" style="margin-top: 10px;">
	<div id="items">
		<div id="top_friends">{Account::AjaxTopFriends}</div>
	</div>
</div>
{literal}
<script type="text/javascript">
	Droppables.add('cart', {
		accept:'products',
		onDrop:function(element)
			{
				if (element.id.substr(0, 4) != "item")
				{
					xajax_displayTopFriends(encodeURIComponent(element.id));
				}
			}});	
</script>
{/literal}
{/if}

<table style="width: 100%;" class="mainmenu5" cellpadding="0" cellspacing="0" border="0">
<tr>
    <td width="7"><img src="design/pic/spacer.gif" class="sqr1" alt="" height="7" width="7" /></td>
    <td class="block_header">{language text="friends_list"}</td>
</tr>
</table>
{if $aFriends}
<br />
<form method="post" action="{url link='public.account.friends'}">
	<label>{language text='Mod_Account.username'}: <input type="text" name="username" value="{$sUserName|escape}" /> <input type="submit" value="{language text='Mod_Account.search'}" /></label>
</form>
<br />
{/if}
{if $sUserName}
<div style="text-align:center;">
	{language text='Mod_Account.found_x_friends' replace=$iCnt}
	<br />
	<br />
</div>
{/if}

{if $aFriends}
    {include file="$sRootPath/_blocks/pager.html"}
    <br />
    <br />
    <table style="width:100%;" cellpadding="5" cellspacing="0">
        <tr class="border13">
        {foreach from=$aFriends item=aFriend name=friends}
            <td style="text-align:center;vertical-align:middle;">
            <table style="margin-left:auto;margin-right:auto;">
                <tr>
                    <td style="font-size:8pt;" class="color">                    
                    <div>
                   		<div><b><a class="link_description" href="{url link='public.user' name=$aFriend.user}"> {$aFriend.user}</a> </b></div>
                   		{Account::Avatar sUser=$aFriend.user iSize=60 onmouseover="showInfo5('`$aFriend.user`', '', '');" onmouseout="return nd();" style="position: relative; z-index: 0; opacity: 0.99999; top: 0px; left: 0px; cursor:move;" class="products" id="`$aFriend.user`"}
                    </div>                    
                    <script type="text/javascript">new Draggable('{$aFriend.user}', {literal}{revert:true})</script>{/literal}
                    <div style="padding:5px;">[ <a href="{url link='public.account.friends' act='delete_friend' mode=$sMode user=$aFriend.user}" onclick="return sure();"> {language text="delete_383"} </a> ]</div>                                             
                    </td>
                </tr>
            </table>
            </td>
            {if $smarty.foreach.friends.iteration % $iRowSize == 0}
            </tr>
            <tr class="{if ($smarty.foreach.friends.iteration/$iRowSize)%2 == 0}border13{/if}">
            {/if}
        {/foreach}
        {if $smarty.foreach.friends.total % $iRowSize != 0}
            <td colspan="{$iRowSize}">&nbsp;</td>
        {/if}
        </tr>
    </table>
    <br />   
    {include file="$sRootPath/_blocks/pager.html"}
    <br />
    <br />
{else}
	{if !$sUserName}
    <table style="width:100%;">
        <tr>
            <td><div class="message_info">{language text="there_are_no_friends_yet"}</div></td>
        </tr>
    </table>
    {/if}
{/if}